﻿@namespace BlazorCharts
@inherits ElementSeries<TData>
@typeparam TData

@if (Chart.IsInit)
{
    <g class="bc-scatter-series" transform="translate(@Rect.LT.ToPoint())">
        @{
            //一个分组就是一组散点
            foreach (var group in SeriesData.Groups)
            {
                var color = (group ?? "Scatter").RandomColor().ToHtml();
                var colorDeepen = (group ?? "Scatter").RandomColor().Deepen().ToHtml();
                List<Point> points = new List<Point>();

                foreach (var category in SeriesData.CategoryDatas)
                {
                    var data = SeriesData.GetValueData<SingleValueData>(category.Name, group);

                    points.Add(new Point((int)(Chart.BcAxisGroup.AxesX.Rect.W * category.ZeroOffsetRatio), Rect.H - GetHeightByValue(data.Value)));
                }

                foreach (var item in points)
                {
                    <circle cx="@(item.X)" cy="@(item.Y)" r="4" fill="@color" class="bc-scatter-translate" />
                }

            }
        }
    </g>

}



<style>
    .bc-scatter-translate {
        animation-name: bc-scatter-animation;
        animation-duration: 1s
    }

    @@keyframes bc-scatter-animation {
        from {
            cy: @Rect.H
        }
    }
</style>